/*************************************************
Author: will
Date: 11/8/2012
Description:
Notes: 
*************************************************/

#ifndef __CCardConfig_h__
#define __CCardConfig_h__

#include "CTArray.h"
#include "../common/CRandom.h"
#include "commerrno.h"
#include "commclass.h"

enum CARD_TYPE 
{
    CARD_TYPE_SILVER = 0,  //银币
    CARD_TYPE_FATE_FORCE = 1,  //命运之力
    CARD_TYPE_GREEN_CARD = 2,   //绿色卡片
    CARD_TYPE_BLUE_CARD = 3,    //蓝色卡片
    CARD_TYPE_PURPLE_CARD = 4,  //紫色卡片
    CARD_TYPE_SOUL_CARD = 5,    //卡魂
    CARD_TYPE_GOLD_CARD = 6,    //金色卡片
    CARD_TYPE_ROMANY = 7,       //吉普赛硬币
    CARD_TYPE_ORANGE_CARD = 8,  //橙色
};

enum
{
    CARD_TYPE_COUNT = 6,
    DROP_GRADE_COUNT = 10,
    DIVINE_DROP_ID_MOD = 10000,
};

//占卜配置
class CDivinePosConfigData
{
public:
    CDivinePosConfigData()
        :_bHasConfig(false)
    {
        _astDivinePosDropSet.m_iUsedCount = _astDivinePosDropSet.GetCount();
    }

    int AddDrop(unsigned char ucDivinePos, unsigned char ucCardType, 
                unsigned short usDropRate, unsigned short usDropCount);

    int Drop(CRateTarget& stDrop, unsigned char ucPos, unsigned short& usDropCount);

public:
    bool _bHasConfig;

    unsigned char _ucDivinePos;     //占卜牌的位置，从1开始
    unsigned int _uiCostSilver;    //银币费用
    unsigned char _ucSuccCardType;   //可继续掉落的卡片类型(enum CARD_TYPE)

    CTLib::CTArray<CRandomSet<MAX_CARD_DIVINE_POS_DROP_TYPE_COUNT>, MAX_CARD_DIVINE_POS_CONIFG + 1>  _astDivinePosDropSet;
};

class CDivinePosConfig
{
public:
    CDivinePosConfig()
    {
    }

    int AddConfig(CDivinePosConfigData& stConfigData);

    int GetConfig(unsigned char ucPos, CDivinePosConfigData& stConfigData);

    int AddGoldDrop(unsigned char ucCardType, unsigned short usDropRate);
    int GoldDrop(CRateTarget& stDrop);

public:
    CTArray<CDivinePosConfigData, MAX_CARD_DIVINE_POS_CONIFG + 1> _astDivinePosConfig;
    CRandomSet<MAX_CARD_GOLD_DIVINE_POS_DROP_TYPE_COUNT> _stGoldDivineDropSet;      //金币占卜配置
};

//卡片升级经验
class CCardLevelConfigData
{
public:
    CCardLevelConfigData()
        :_bHasConfig(false)
    {
        _usLevel = 0;
        _uiType2Exp = 0;
        _uiType3Exp = 0;
        _uiType4Exp = 0;
        _uiType5Exp = 0;
        _uiType6Exp = 0;
        _uiType8Exp = 0;
    }

    int GetExp(unsigned char ucCardType, unsigned int& uiExp);
    
    CCardLevelConfigData& operator+=(const CCardLevelConfigData& stData);

public:
    bool _bHasConfig;

    unsigned short _usLevel;

    unsigned int _uiType2Exp;       //绿色卡片升级经验
    unsigned int _uiType3Exp;       //蓝色卡片升级经验
    unsigned int _uiType4Exp;       //紫色卡片升级经验
    unsigned int _uiType5Exp;       //卡魂升级经验
    unsigned int _uiType6Exp;       //金色卡片升级经验
    unsigned int _uiType8Exp;       //橙色卡片
};

class  CCardLevelConfig
{
public:
    CCardLevelConfig()
    {
    }

    int AddConfig(CCardLevelConfigData& stConfigData);

    int GetConfig(unsigned short usLevel, unsigned char ucCardType, unsigned int& uiExp);

    int GetPointConfig(unsigned short usLevel, unsigned char ucCardType, unsigned int& uiPoint);

public:
    CCardLevelConfigData _stMaxLevelConfigData;
    CTLib::CTArray<CCardLevelConfigData, MAX_CARD_LEVEL + 1> _astCardLevelConfig;
    CTLib::CTArray<CCardLevelConfigData, MAX_CARD_LEVEL + 1> _astCardBasePoint;     //用来记录卡片基础分数
};

//卡片列表
class CCardConfigData
{
public:
    CCardConfigData()
        : _bHasConfig(false) , _bCanExchange(false)
    {

    }

public:
    bool _bHasConfig;

    unsigned short _usCardConfigID;
    unsigned char _ucCardType;
    
    unsigned short _usCardPoint;
    bool           _bDefaultCanWare;

    unsigned char _ucAttrType1;
    unsigned short _usAttrValue1;
    unsigned char _ucAttrType2;
    unsigned short _usAttrValue2;

    CTLib::CTArray<int, DROP_GRADE_COUNT> _astDropRate;

    bool _bCanExchange; 
    unsigned short _usExchangeLevel;    //兑换等级
    int     _iExchangePrice;            //兑换价格（吉普赛硬币）

    void GetAttr(CPlayerAttr& stAttr)
    {
        stAttr.AddAttr(_ucAttrType1, _usAttrValue1);
        stAttr.AddAttr(_ucAttrType2, _usAttrValue2);
    }
};

class CCardDrop
{
public:
    typedef CRandomSet<MAX_CARD_CONFIG_COUNT_PER_TYPE> T_CARD_DROP_SET_PER_TYPE;
    typedef CTLib::CTArray<T_CARD_DROP_SET_PER_TYPE, CARD_TYPE_COUNT> T_CARD_DROP_SET_PER_GRAD; //5表示最多5种卡片
    typedef CTLib::CTArray<T_CARD_DROP_SET_PER_GRAD, DROP_GRADE_COUNT + 1> T_CARD_DROP_SET;         //10表示10个等级区间

    CCardDrop();
    char GetLevelGrad(unsigned short usLevel);

    int GetCardIndex(unsigned char ucCardType);
    int GetGoldCardIndex(unsigned char ucCardType);  //金币占卜用索引

    int AddDropData(char cLevelGrad, unsigned char ucCardType,
                    unsigned short usCardConfigID, int iDropRate);

    int Drop(unsigned short usLevel, unsigned char ucCardType, unsigned short& usCardConfigID);

    //金币占卜用掉落
    int GoldDrop(unsigned short usLevel, unsigned char ucCardType, unsigned short& usCardConfigID);

public:
    T_CARD_DROP_SET _astCardDropSet;
    T_CARD_DROP_SET _astGoldCardDropSet;    //金币占卜用配置
};

class CCardConfig
{
public:
    CCardConfig()
    {

    }

    int AddConfig(CCardConfigData& stConfigData);

    int GetConfig(unsigned short usCardConfigID, CCardConfigData& stConfigData);

    int Drop(unsigned short usLevel, unsigned char ucCardType, unsigned short& usCardConfigID);
    int GoldDrop(unsigned short usLevel, unsigned char ucCardType, unsigned short& usCardConfigID);

public:
    CTLib::CTArray<CCardConfigData, MAX_CARD_CONFIG_COUNT + 1> _astCardConfig;
    CCardDrop                                           _stCardDrop;
};

//命运漩涡升级表
class CVortexConfigData
{
public:
    CVortexConfigData()
        :_bHasConfig(false)
    {
        _usLevel = 0;
        _uiNeedFateForceCount = 0;
        _usAddProp = 0;
    }

public:
    bool _bHasConfig;

    unsigned short _usLevel;
    unsigned int   _uiNeedFateForceCount;
    unsigned short _usAddProp;                  //提升比例
    unsigned int   _uiExtractNeedSilver;        //抽取所需银币
    unsigned int   _uiExtractToZeroNeedSilver; //降到0级所需要的银币
};

class CVortexConfig
{
public:
    CVortexConfig()
        :usMaxLevel(0)
    {

    }

    int AddConfig(CVortexConfigData& stConfigData);

    int GetConfig(unsigned short usLevel, CVortexConfigData& stConfigData);

public:
    unsigned short usMaxLevel;
    CTLib::CTArray<CVortexConfigData, MAX_VORTEX_CONFIG_COUNT + 1> _astVortexConfigDatas;
};

/*
class CCardShopConfigData
{
    CCardShopConfigData()
    {

    }

public:
    bool _bHasConfig;

    
};
*/

#endif // __CCardConfig_h__

